package com.drug.mingkang.service.impl;

import com.drug.mingkang.model.HqChargeoff;
import com.drug.mingkang.Mapper.HqChargeoffMapper;
import com.drug.mingkang.service.HqChargeoffService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 出账明细(HqChargeoff)表服务实现类
 *
 * @author wenchangjian
 * @since 2020-08-11 11:28:42
 */
@Service("hqChargeoffService")
public class HqChargeoffServiceImpl implements HqChargeoffService {
    @Resource
    private HqChargeoffMapper hqChargeoffMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param chargeoffId 主键
     * @return 实例对象
     */
    @Override
    public HqChargeoff queryById(String chargeoffId) {
        return this.hqChargeoffMapper.queryById(chargeoffId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<HqChargeoff> queryAllByLimit(int offset, int limit) {
        return this.hqChargeoffMapper.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param hqChargeoff 实例对象
     * @return 实例对象
     */
    @Override
    public HqChargeoff insert(HqChargeoff hqChargeoff) {
        this.hqChargeoffMapper.insert(hqChargeoff);
        return hqChargeoff;
    }

    /**
     * 修改数据
     *
     * @param hqChargeoff 实例对象
     * @return 实例对象
     */
    @Override
    public HqChargeoff update(HqChargeoff hqChargeoff) {
        this.hqChargeoffMapper.update(hqChargeoff);
        return this.queryById(hqChargeoff.getChargeoffId());
    }

    /**
     * 通过主键删除数据
     *
     * @param chargeoffId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(String chargeoffId) {
        return this.hqChargeoffMapper.deleteById(chargeoffId) > 0;
    }
}